package com.jucai.pppeiyouclient.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.google.gson.Gson;
import com.jucai.pppeiyouclient.MainActivity;
import com.jucai.pppeiyouclient.ProjectGlobalVar;
import com.jucai.pppeiyouclient.R;
import com.jucai.pppeiyouclient.base.BaseActivity;
import com.jucai.pppeiyouclient.bean.AccompanyBean;
import com.jucai.pppeiyouclient.comm.CommonRequestNetData;
import com.jucai.pppeiyouclient.utils.ActivityCollector;
import com.jucai.pppeiyouclient.utils.VersionInfoUtil;

import org.json.JSONObject;

import java.util.HashMap;

import static com.jucai.pppeiyouclient.view.activity.LoginActivity.activity;

/**
 * 2017-5-14 11:34:23 修改
 */
public class AboutActivity extends BaseActivity {

    private TextView aboutFeedback;
    private AccompanyBean accompany;
    private TextView tvVersion;

    @Override
    protected void initView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_about);
        ((TextView) findViewById(R.id.common_title_text)).setText("关于优约");
        aboutFeedback = (TextView) findViewById(R.id.about_feedback);
        tvVersion = (TextView) findViewById(R.id.tv_version);
    }

    @Override
    protected void initData() {
        tvVersion.setText("版本V "+ ProjectGlobalVar.version/*VersionInfoUtil.getAppVersionName(activity)*/);
    }

    @Override
    protected void loadNetData() {

    }

    private void getPersonInfo() {

        HashMap<String, String> param = new HashMap<>();
        param.put("service", "Accompany_Info.getAccompanyInfo");

        CommonRequestNetData.getJsonObjectData(this, param, false, new CommonRequestNetData.JsonObjectCallBack() {

            @Override
            public void parseJsonObject(JSONObject jsonObject) {
//                LogUtils.e(TAG + "jsObj = " + jsonObject.toString());
                accompany = new Gson().fromJson(jsonObject.toString(), AccompanyBean.class);
//                LogUtils.e(TAG + "accompany = " + accompany);
               /* runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Glide.with(AboutActivity.this)
                                .load(accompany.getMember_avatar())
                               .override(80, 80)
                                .centerCrop()
                                .into(personImage);

                        personNick.setText(accompany.getMember_realname());
                        personAge.setText(accompany.getMember_age());
                        personCareer.setText(accompany.getMember_occupation());
                        personEdu.setText(accompany.getMember_education());
                        personIntro.setText(accompany.getMember_desc());
                        Selection.setSelection(personAge.getText(), personAge.getText().length());
                    }
                });*/
            }
        });
    }

    @Override
    protected void setListener() {
        findViewById(R.id.common_back).setOnClickListener(this);
        findViewById(R.id.common_home_back).setOnClickListener(this);
        aboutFeedback.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.common_back:
                ActivityCollector.removeActivity(this);
                break;

            case R.id.common_home_back:
                startActivity(new Intent(AboutActivity.this, MainActivity.class));
                ActivityCollector.removeActivity(this);
                break;

            case R.id.about_feedback:
                startActivity(new Intent(AboutActivity.this, FeedbackActivity.class));
                break;
        }
    }
}
